home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_u_z / wedl203.zip / WEDL.H < prev    next >
Text File  |  1992-07-30  |  19KB  |  371 lines

  1.  
  2. /*---------------------------------------------------------------------------*/
  3. /*                                                                           */
  4. /*          WEDL(tm) - Windows Enhanced Dialog Library                       */
  5. /*          Copyright (c) 1991-1992, Nemisoft, Inc.                          */
  6. /*          All Rights Reserved                                              */
  7. /*          Module:  WEDL.H                                                  */
  8. /*                                                                           */
  9. /*---------------------------------------------------------------------------*/
  10.  
  11. #if !defined( __WEDL_H )
  12.     #define __WEDL_H
  13.  
  14. /*---------------------------------------------------------------------------*/
  15.  
  16. /* Windows 3.0 SDK compatibility */
  17.  
  18. #if !defined( WINAPI )
  19.     #define CALLBACK FAR PASCAL
  20.     #define WINAPI FAR PASCAL
  21.     typedef unsigned int UINT;
  22.     typedef UINT WPARAM;
  23.     typedef LONG LPARAM;
  24.     typedef LONG LRESULT;
  25.     typedef HANDLE HINSTANCE;
  26.     typedef HANDLE HDROP;
  27.     typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
  28. #endif
  29.  
  30. /*---------------------------------------------------------------------------*/
  31.  
  32. /* form feature definitions */
  33.  
  34. #define FMF_NONE        0L      /* no features specified                  */
  35. #define FMF_OVERTYPE    1L      /* set Insert mode off by default         */
  36. #define FMF_UPDATE      2L      /* set all controls in update mode        */
  37. #define FMF_VKEYPRES    4L      /* perform validation after each keypress */
  38. #define FMF_VLEAVFLD    8L      /* do validation when user leaves field   */
  39. #define FMF_NOSELECT    16L     /* no auto-select of fields upon focus    */
  40. #define FMF_COMPAT      32L     /* compatibility mode                     */
  41.  
  42. /*---------------------------------------------------------------------------*/
  43.  
  44. /* field feature definitions */
  45.  
  46. #define FDF_NONE        0L      /* no features specified                  */
  47. #define FDF_COMPLETE    1L      /* field must be complete                 */
  48. #define FDF_NOTBLANK    2L      /* field cannot be blank                  */
  49. #define FDF_NOTZERO     4L      /* field cannot be zero                   */
  50. #define FDF_NOTEDIT     8L      /* field cannot be edited                 */
  51. #define FDF_MUSTEDIT    16L     /* field must be edited                   */
  52. #define FDF_UPDATE      32L     /* update existing data                   */
  53. #define FDF_NOSELECT    64L     /* no auto-select of field upon focus     */
  54. #define FDF_SPCFILL     128L    /* space-fill field from right            */
  55. #define FDF_ZEROFILL    256L    /* zero-fill numeric field from left      */
  56. #define FDF_BLNKZERO    512L    /* blank numeric field if equal to zero   */
  57. #define FDF_BLNKNEZ     1024L   /* blank not equal zero (numeric field)   */
  58. #define FDF_PHYSICAL    2048L   /* read/write data in physical format     */
  59. #define FDF_UPPER       4096L   /* convert characters to UPPERCASE        */
  60. #define FDF_LOWER       8192L   /* convert characters to lowercase        */
  61. #define FDF_PROPER      16384L  /* convert characters to Proper Case      */
  62. #define FDF_NUMERIC     32768L  /* standard numeric field                 */
  63. #define FDF_CALCNUM     65536L  /* calculator-style numeric field         */
  64. #define FDF_VKEYPRES    131072L /* perform validation after each keypress */
  65. #define FDF_VLEAVFLD    262144L /* do validation when user leaves field   */
  66. #define FDF_COMBO       524288L /* field belongs to a combo box           */
  67.  
  68. /*---------------------------------------------------------------------------*/
  69.  
  70. /* enable-link condition definitions */
  71.  
  72. #define ELC_BLANK       1L      /* field is blank                    */
  73. #define ELC_ZERO        2L      /* field contains a zero value       */
  74. #define ELC_EDITED      3L      /* field has been edited by the user */
  75. #define ELC_CHECKED     4L      /* button is checked                 */
  76.  
  77. /*---------------------------------------------------------------------------*/
  78.  
  79. /* field data type definitions */
  80.  
  81. #define FDT_NULL        0       /* 'pdata' pointer == NULL      */
  82. #define FDT_STRING      1       /* character string             */
  83. #define FDT_SHORT       2       /* 16-bit signed integer        */
  84. #define FDT_USHORT      3       /* 16-bit unsigned integer      */
  85. #define FDT_INTEGER     4       /* signed integer               */
  86. #define FDT_UNSIGNED    5       /* unsigned integer             */
  87. #define FDT_LONG        6       /* 32-bit signed long integer   */
  88. #define FDT_ULONG       7       /* 32-bit unsigned long integer */
  89. #define FDT_FLOAT       8       /* single precision real number */
  90. #define FDT_DOUBLE      9       /* double precision real number */
  91.  
  92. /*---------------------------------------------------------------------------*/
  93.  
  94. /* button feature definitions */
  95.  
  96. #define BTF_NONE        0L      /* no features specified                    */
  97. #define BTF_CHECKED     1L      /* button is initially checked              */
  98. #define BTF_GRAYED      2L      /* button is initially grayed               */
  99. #define BTF_UPDATE      4L      /* button is initialize according to pdata  */
  100. #define BTF_GENERIC     8L      /* button record holds generic control info */
  101. #define BTF_IDOK        16L     /* button is the "OK" button                */
  102. #define BTF_IDCANCEL    32L     /* button is the "Cancel" button            */
  103.  
  104. /*---------------------------------------------------------------------------*/
  105.  
  106. /* key status message definitions */
  107.  
  108. #define KSM_INSERT      0       /* Insert key status message    */
  109. #define KSM_CAPSLOCK    1       /* CapsLock key status message  */
  110. #define KSM_NUMLOCK     2       /* NumLock key status message   */
  111.  
  112. /*---------------------------------------------------------------------------*/
  113.  
  114. /* internal field error values (don't use these for your own error values) */
  115.  
  116. #define ERV_BLANK       27701   /* field is blank                       */
  117. #define ERV_INCOMPL     27702   /* field is incomplete                  */
  118. #define ERV_INVCHAR     27703   /* field contains invalid character(s)  */
  119. #define ERV_NOTEDIT     27704   /* user tried to edit noneditable field */
  120. #define ERV_UNEDITED    27705   /* field hasn't been edited             */
  121. #define ERV_ZERO        27706   /* field has a value of zero            */
  122.  
  123. /*---------------------------------------------------------------------------*/
  124.  
  125. /* error event definitions */
  126.  
  127. #define ERE_KEYPRESS    1       /* a key was pressed                 */
  128. #define ERE_LEAVEFLD    2       /* user attempted to leave the field */
  129. #define ERE_SELECTOK    3       /* user attempted to select "OK"     */
  130.  
  131. /*---------------------------------------------------------------------------*/
  132.  
  133. /* definitions of WEDL handles */
  134.  
  135. typedef HANDLE  HFORM;          /* handle of a form record   */
  136. typedef HANDLE  HFIELD;         /* handle of a field record  */
  137. typedef HANDLE  HBUTTON;        /* handle of a button record */
  138.  
  139. /*---------------------------------------------------------------------------*/
  140.  
  141. /* function pointer definitions for error handling and validation functions */
  142.  
  143. typedef BOOL (CALLBACK *PERRFUNC) (HFORM,HFIELD,int,int,int);
  144. typedef int (CALLBACK *PVALFUNC) (HFORM,HFIELD,LPSTR);
  145.  
  146. /*---------------------------------------------------------------------------*/
  147.  
  148. /* definition of a field record */
  149.  
  150. typedef struct {
  151.     DWORD features;             /* field features                            */
  152.     DWORD help_context;         /* help context ID of help topic for field   */
  153.     LPSTR picture_string;       /* pointer to the field picture string       */
  154.     LPVOID pdata;               /* pointer to data type to write/update      */
  155.     PVALFUNC pvalid_func;       /* proc-instance address of validation func. */
  156.     HWND hcombo;                /* handle of combo box field belongs to      */
  157.     HWND hwnd;                  /* field's window handle                     */
  158.     HFIELD hfield;              /* field's memory handle                     */
  159.     HFIELD hnext_field;         /* handle of next field in linked list       */
  160.     int ctrl_id;                /* dialog control ID of edit control         */
  161.     int data_type;              /* data type pointed to by 'data' parameter  */
  162.     int decimal_position;       /* virtual logical position of decimal point */
  163.     int error_value;            /* unique error value                        */
  164.     int logical_size;           /* logical size of field                     */
  165.     int physical_size;          /* physical size of field                    */
  166.     BOOL has_changed;           /* flag - "field has changed"                */
  167. } FIELD;
  168.  
  169. typedef FIELD *     PFIELD;
  170. typedef FIELD FAR * LPFIELD;
  171.  
  172. /*---------------------------------------------------------------------------*/
  173.  
  174. /* field position information */
  175.  
  176. typedef struct {
  177.     LPSTR ppicture_str_pos;     /* pointer to picture string position      */
  178.     long selection;             /* selection                               */
  179.     int logical_position;       /* logical position                        */
  180.     int physical_position;      /* physical position                       */
  181.     int val_char_occ;           /* validation character occurrence         */
  182.     BOOL to_right_of_dec;       /* position is to the right of the decimal */
  183.     char validation_char;       /* validation character for position       */
  184. } FIELD_POS;
  185.  
  186. typedef FIELD_POS *     PFIELD_POS;
  187. typedef FIELD_POS FAR * LPFIELD_POS;
  188.  
  189. /*---------------------------------------------------------------------------*/
  190.  
  191. /* definition of a form record */
  192.  
  193. typedef struct {
  194.     DWORD features;             /* form features                            */
  195.     PERRFUNC perror_func;       /* proc-instance address of error handler   */
  196.     FARPROC pdialog_proc;       /* address of dialog box's window procedure */
  197.     DWORD help_context;         /* default Windows Help context             */
  198.     LPSTR capslock_offmsg;      /* pointer to CapsLock "off" status message */
  199.     LPSTR capslock_onmsg;       /* pointer to CapsLock "on" status message  */
  200.     LPSTR help_file_name;       /* help file name                           */
  201.     LPSTR insert_offmsg;        /* pointer to Insert "off" status message   */
  202.     LPSTR insert_onmsg;         /* pointer to Insert "on" status message    */
  203.     LPSTR numlock_offmsg;       /* pointer to NumLock "off" status message  */
  204.     LPSTR numlock_onmsg;        /* pointer to NumLock "on" status message   */
  205.     long undo_selection;        /* undo selection                           */
  206.     HANDLE hhead_elink;         /* handle of head enable-link record        */
  207.     HANDLE hproc_array;         /* handle of window procedure array         */
  208.     HANDLE hundo_buffer1;       /* handle of field undo buffer #1           */
  209.     HANDLE hundo_buffer2;       /* handle of field undo buffer #2           */
  210.     HWND hdlg;                  /* form's dialog box window handle          */
  211.     HFORM hform;                /* form's memory handle                     */
  212.     HFORM hnext_form;           /* handle of next form in linked list       */
  213.     HFIELD hcurr_field;         /* handle of current node in field list     */
  214.     HFIELD herror_field;        /* handle of field in error                 */
  215.     HFIELD hhead_field;         /* handle of head node in field list        */
  216.     HBUTTON hhead_button;       /* handle of head node in button list       */
  217.     int cancel_id;              /* control ID of "Cancel" button            */
  218.     int capslock_id;            /* control ID of CapsLock status message    */
  219.     int error_event;            /* event which caused the error             */
  220.     int error_position;         /* logical position of the error            */
  221.     int error_value;            /* error value of field in error            */
  222.     int insert_id;              /* control ID of Insert status message      */
  223.     int numlock_id;             /* control ID of NumLock status message     */
  224.     int num_controls;           /* number of defined controls in form       */
  225.     int ok_id;                  /* control ID of "OK" button                */
  226.     int undo_level;             /* undo level                               */
  227.     BOOL edit_key_pressed;      /* flag - "an editing key was pressed"      */
  228.     BOOL help_invoked;          /* flag - "Windows Help has been invoked"   */
  229.     BOOL insert_mode;           /* flag - "insert mode on"                  */
  230.     BOOL in_error_handler;      /* flag - "in field error handler"          */
  231.     BOOL just_passed_dec;       /* flag - "just passed decimal point"       */
  232.     BOOL pressed_cancel;        /* flag - "Cancel was pressed"              */
  233. } FORM;
  234.  
  235. typedef FORM *     PFORM;
  236. typedef FORM FAR * LPFORM;
  237.  
  238. /*---------------------------------------------------------------------------*/
  239.  
  240. /* definition of a button record */
  241.  
  242. typedef struct {
  243.     DWORD features;             /* button features                          */
  244.     DWORD help_context;         /* help context ID of help topic for button */
  245.     LPINT pdata;                /* pointer to data to initialize/update     */
  246.     HWND hwnd;                  /* button's window handle                   */
  247.     HBUTTON hbutton;            /* handle of button's window                */
  248.     HBUTTON hnext_button;       /* handle of next button in linked list     */
  249.     int ctrl_id;                /* dialog control ID of button              */
  250.     int group_id;               /* group affiliation ID                     */
  251.     int off_value;              /* value stored at 'pdata' if not checked   */
  252.     int on_value;               /* value stored at 'pdata' if checked       */
  253.     BOOL has_changed;           /* flag - "button has changed"              */
  254. } BUTTON;
  255.  
  256. typedef BUTTON *     PBUTTON;
  257. typedef BUTTON FAR * LPBUTTON;
  258.  
  259. /*---------------------------------------------------------------------------*/
  260.  
  261. #if defined(__cplusplus)
  262.     extern "C" {
  263. #endif
  264.  
  265. /* button functions */
  266.  
  267. HBUTTON  WINAPI button_define( HFORM hform, int ctrl_id, LPINT pdata,
  268.                                int group_id, int on_value, int off_value,
  269.                                DWORD features, DWORD help_context );
  270. int      WINAPI button_get_check( HBUTTON hbutton );
  271. HBUTTON  WINAPI button_get_from_ctrl_id( HFORM hform, int ctrl_id );
  272. HBUTTON  WINAPI button_get_from_group( HFORM hform, int group_id );
  273. HBUTTON  WINAPI button_get_from_hwnd( HFORM hform, HWND hWnd );
  274. HWND     WINAPI button_get_hwnd( HBUTTON hbutton );
  275. BOOL     WINAPI button_has_changed( HBUTTON hbutton );
  276. LPBUTTON WINAPI button_lock( HBUTTON hbutton );
  277. int      WINAPI button_set_check( HBUTTON hbutton, int state );
  278. void     WINAPI button_unlock( HBUTTON hbutton );
  279.  
  280. /*---------------------------------------------------------------------------*/
  281.  
  282. /* character manipulation functions */
  283.  
  284. BOOL WINAPI char_is_printable( int ch );
  285. int  WINAPI char_to_lower( int ch );
  286. int  WINAPI char_to_upper( int ch );
  287.  
  288. /*---------------------------------------------------------------------------*/
  289.  
  290. /* field functions */
  291.  
  292. int     WINAPI field_data_to_log( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  293.                                   int data_type );
  294. HFIELD  WINAPI field_define( HFORM hform, int ctrl_id, LPVOID pdata,
  295.                              int data_type, LPSTR picture_string,
  296.                              DWORD features, PVALFUNC pvalid_func,
  297.                              int error_value, DWORD help_context );
  298. int     WINAPI field_get_character( HFIELD hfield, int position,
  299.                                     BOOL physical );
  300. int     WINAPI field_get_ctrl_id( HFIELD hfield );
  301. HFIELD  WINAPI field_get_from_ctrl_id( HFORM hform, int ctrl_id );
  302. HFIELD  WINAPI field_get_from_hwnd( HFORM hform, HWND hWnd );
  303. HWND    WINAPI field_get_hwnd( HFIELD hfield );
  304. int     WINAPI field_get_pos_info( HFIELD hfield, int logical_position,
  305.                                    LPFIELD_POS pfpos );
  306. int     WINAPI field_get_position( HFIELD hfield, LPFIELD_POS pfpos );
  307. int     WINAPI field_get_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  308. BOOL    WINAPI field_has_changed( HFIELD hfield );
  309. LPFIELD WINAPI field_lock( HFIELD hfield );
  310. int     WINAPI field_log_to_data( HFIELD hfield, LPSTR pbuf, LPVOID pdata,
  311.                                   int data_type );
  312. int     WINAPI field_log_to_phys( HFIELD hfield, LPSTR pbuf );
  313. int     WINAPI field_phys_to_log( HFIELD hfield, LPSTR pbuf );
  314. int     WINAPI field_set_text( HFIELD hfield, LPSTR pbuf, BOOL physical );
  315. void    WINAPI field_unlock( HFIELD hfield );
  316.  
  317. /*---------------------------------------------------------------------------*/
  318.  
  319. /* form functions */
  320.  
  321. HFORM  WINAPI form_begin( HWND hDlg, DWORD features, PERRFUNC perror_func );
  322. int    WINAPI form_cancel( HFORM hform );
  323. int    WINAPI form_end( HFORM hform );
  324. BOOL   WINAPI form_exists( HFORM hform );
  325. HFORM  WINAPI form_get_from_hdlg( HWND hDlg );
  326. HWND   WINAPI form_get_hdlg( HFORM hform );
  327. BOOL   WINAPI form_has_changed( HFORM hform );
  328. BOOL   WINAPI form_in_error_cond( HFORM hform );
  329. BOOL   WINAPI form_is_cancelled( HFORM hform );
  330. int    WINAPI form_load( HFORM hform );
  331. LPFORM WINAPI form_lock( HFORM hform );
  332. int    WINAPI form_ok( HFORM hform );
  333. int    WINAPI form_save( HFORM hform );
  334. int    WINAPI form_set_enable_link( HFORM hform, HANDLE hcontrol,
  335.                                     DWORD condition, int ctrl_id,
  336.                                     BOOL enable );
  337. int    WINAPI form_set_help( HFORM hform, LPSTR help_file_name,
  338.                              DWORD help_context );
  339. void   WINAPI form_unlock( HFORM hform );
  340. HFIELD WINAPI form_validate( HFORM hform );
  341.  
  342. /*---------------------------------------------------------------------------*/
  343.  
  344. /* generic control functions */
  345.  
  346. HANDLE WINAPI generic_define( HFORM hform, int ctrl_id, DWORD help_context );
  347.  
  348. /*---------------------------------------------------------------------------*/
  349.  
  350. /* key status message functions */
  351.  
  352. int WINAPI keystat_define( HFORM hform, int ctrl_id, int which,
  353.                            LPSTR onmsg, LPSTR offmsg );
  354.  
  355. /*---------------------------------------------------------------------------*/
  356.  
  357. /* string manipulation functions */
  358.  
  359. int  WINAPI str_delete_char( LPSTR pstr, int ch );
  360. void WINAPI str_insert_char( LPSTR pstr, int ch, int offs );
  361. BOOL WINAPI str_is_blank( LPSTR pstr );
  362. BOOL WINAPI str_is_value_zero( LPSTR pstr );
  363. void WINAPI str_trim_spaces( LPSTR pstr );
  364.  
  365. #if defined(__cplusplus)
  366.     }
  367. #endif
  368.  
  369. #endif  /* __WEDL_H */
  370.  
  371.